package com.dropgame.tools;

import aurelienribon.tweenengine.TweenAccessor;

public class SpriteButtonAccessor implements TweenAccessor<SpriteButton>{

	public static final int POSITION_X = 1;
	public static final int POSITION_Y = 2;
	public static final int POSITION_XY = 3;
	public static final int SCALE = 4;
	
	@Override
	public int getValues(SpriteButton target, int tweenType, float[] returnValues) {
		switch (tweenType){
		case POSITION_X: returnValues[0] = target.xPos; return 1;
		case POSITION_Y: returnValues[0] = target.yPos; return 1;
		case POSITION_XY:
            returnValues[0] = target.xPos;
            returnValues[1] = target.yPos;
            return 2;
		case SCALE: 
        	returnValues[0] = target.keyFrame.getScaleX();
        	returnValues[1] = target.keyFrame.getScaleY();
        	return 2;
		default: assert false; return -1;
		
		}
		
	}

	@Override
	public void setValues(SpriteButton target, int tweenType, float[] newValues) {
		switch (tweenType) {
		case POSITION_X: target.xPos = (int) (newValues[0]); break;
		case POSITION_Y: target.yPos = (int) (newValues[0]); break;
		case POSITION_XY: 
			target.xPos = (int)(newValues[0]);
			target.yPos = (int)(newValues[1]);
            break;
		case SCALE:
        	target.keyFrame.setScale(newValues[0], target.keyFrame.getScaleY());
        	target.keyFrame.setScale(target.keyFrame.getScaleX(), newValues[1]);
        	break;
        default: assert false; break;
		}
		
	}

}
